package com.example.demo01minio.domain;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;

/**
 * ClassName:TUser
 * Package:com.example.demo01minio.domain
 * Description:
 *
 * @Author:helei
 * @Create:2024/8/27 - 11:38
 */
@TableName(value = "t_user") //mp映射表名的注解 mp优先使用注解中的表名，最后使用类名
@Schema(description = "用户实体类")
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder //使用构建者设计模式来生成builder和build方法创建TUser对象
public class TUser implements Serializable {
    @Schema(description = "主键值", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @TableId(value = "id", type = IdType.ASSIGN_ID) //使用雪花算法生成id 映射表的主键
//    @TableId(type = IdType.AUTO) //使用数据库自增
    private Long id;

    @Schema(description = "用户名", example = "zhangsan")
    private String username;

    @Schema(description = "邮箱", example = "10086@abc.com")
    private String email;

    @Schema(description = "年龄", hidden = true)
    private Integer age;

    @TableField(fill = FieldFill.INSERT)
    @Schema(description = "创建时间")
    private Date createTime;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    @Schema(description = "更新时间")
    private Date updateTime;

    @TableField(value = "is_deleted") //指定当前属性在表中的列名，mp优先使用注解中的列名，最后使用属性名
    @Schema(description = "逻辑删除", hidden = true)
    @TableLogic //表示当前字段为逻辑删除字段：查询时自动添加 deleted=0,删除时自动更新该字段为1
    private Boolean deleted;

    @TableField(exist = false) //表示扩展属性，数据库表不存在的属性，mp生成sql时会忽略
    private String password;
}
